<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\models\PostStatus;

/* @var $this yii\web\View */
/* @var $searchModel common\models\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '文章管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php //echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?= Html::a('发表文章', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
//             ['class' => 'yii\grid\SerialColumn'],
            ['attribute'=>'id',
             'contentOptions'=>['width'=>'30px'],
            ],
            'title',
            ['attribute'=>'authorName',
             'label'=>'作者',
             'value'=>'author.nickname'
            ],
            //'content:ntext',
            'tags:ntext',
            ['attribute'=>'status',
             'value'=>'postStatus.name',
             'filter'=>PostStatus::find()
                    ->select(['name','id'])
                    ->orderBy('position')
                    ->indexBy('id')
                    ->column(),
            ],
            // 'create_time:datetime',
            ['attribute'=>'update_time',
             'format'=>['date','php:Y年m月d日 H:i:s']
            ],
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
